package edu.bu.cs673.superkids123.children.model;

import java.util.Set;
import java.util.HashSet;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import edu.bu.cs673.superkids123.common.model.Child;
@Entity
@Table(name="Levels")
public class Level {
	
	/**
	 * @author Abdelghani Bhalla
	 */
	
	@Id @GeneratedValue
	@Column(name="LevelID")
	private int id;
	
	@Column(name="LevelName")
	private String name;
	
	@Column(name="LevelDescription")
	private String description;
	
	@Column(name="LevelMinAge")
	private int minAge;
	
	@Column(name="LevelMaxAge")
	private int maxAge;
	
	@OneToMany(mappedBy="level")
	private Set<Lesson> lessons = new HashSet<Lesson>();
	
	@OneToMany(mappedBy="level")
	private Set<Game> games = new HashSet<Game>();
	
	@OneToMany(mappedBy="level", fetch=FetchType.EAGER)
	private Set<Child> children = new HashSet<Child>();
	
	 
	public Set<Child> getChildren() {
		return children;
	}
	public void setChildren(Set<Child> children) {
		this.children = children;
	}
	public Set<Lesson> getLessons() {
		return lessons;
	}
	public void setLessons(Set<Lesson> lessons) {
		this.lessons = lessons;
	}
	public Set<Game> getGames() {
		return games;
	}
	public void setGames(Set<Game> games) {
		this.games = games;
	}
	
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	public int getMinAge() {
		return minAge;
	}
	public void setMinAge(int minAge) {
		this.minAge = minAge;
	}
	public int getMaxAge() {
		return maxAge;
	}
	public void setMaxAge(int maxAge) {
		this.maxAge = maxAge;
	}
	
	public void addChild(Child c)
	{
		c.setLevel(this);
		children.add(c);
	}
	
	public void addLesson(Lesson l)
	{
		l.setLevel(this);
		lessons.add(l);
	}
	public void addGame(Game g)
	{
		g.setLevel(this);
		games.add(g);
	}
	public Level(String name, String description, int minAge, int maxAge)
	{
		this.name = name;
		this.description = description;
		this.minAge = minAge;
		this.maxAge = maxAge;
	}
	public Level(){
		
	}
	

}
